<template>
  <section class="page">
    <!-- 标题 -->
    <div class="title">
      <div>Purchase Order Revise</div>
    </div>
    <!-- 表单字段 -->
    <div class="form">
      <div class="form-row">
        <div>Supplier: {{ propsForm.newSupplier }}</div>
        <div>Order Date: {{ (propsForm.orderDate || '').slice(0, 10) }}</div>
        <div>Revise Date: {{ (propsForm.reviseDate || '').slice(0, 10) }}</div>
        <div>Order No: {{ propsForm.orderNO }}</div>
      </div>
    </div>
    <!-- 表格 -->
    <table style="width: 100%" border="1" cellspacing="0">
      <thead>
        <tr class="text-center bg-color">
          <th class="table-col-short">Seq</th>
          <th class="table-col-long" colspan="2">Material Name</th>
          <th class="table-col-short">Unit</th>
          <th class="table-col">Price</th>
          <th class="table-col">Money</th>
        </tr>
      </thead>
      <tbody>
        <template v-for="(item, index) in propsForm.detailList">
          <tr :key="index">
            <td rowspan="2" class="text-center">
              {{ item.seq }}
            </td>
            <td class="table-col-mini" style="color: blue;">
              Old
            </td>
            <td class="text-left">
              {{ item.oldMaterialName }}
            </td>
            <td class="text-center">
              {{ item.oldUnit }}
            </td>
            <td class="text-right">
              {{ $util.formatPrice(item.oldPrice) }}
            </td>
            <td class="text-right">
              {{ $util.formatPrice(item.oldMoney) }}
            </td>
          </tr>
          <tr :key="10000 + index">
            <td class="table-col-mini" style="color: red;">
              New
            </td>
            <td class="text-left">
              {{ item.newMaterialName }}
            </td>
            <td class="text-center">
              {{ item.newUnit }}
            </td>
            <td class="text-right">
              {{ $util.formatPrice(item.newPrice) }}
            </td>
            <td class="text-right">
              {{ $util.formatPrice(item.newMoney) }}
            </td>
          </tr>
        </template>
      </tbody>
    </table>
    <div class="base-stamp">
      <table cellspacing="0" cellpadding="0" border="0" class="el-table__header table-flow">
        <thead class="has-gutter">
          <tr class="text-left">
            <th><div class="examine-cell">签核角色</div></th>
            <th><div class="examine-cell">审核人员</div></th>
            <th><div class="examine-cell">审核状况</div></th>
            <th><div class="examine-cell">审核意见</div></th>
            <th><div class="examine-cell">审核时间</div></th>
          </tr>
        </thead>
        <tbody>
          <template >
            <tr class="text-left" v-for="(item, index) in (propsForm.qhChkmgrdList || [])" :key="index">
              <td><div>{{item.flowDesc}}</div></td>
              <td><div>{{item.toUserCname}}</div></td>
              <td><div>{{item.chkStatusName}}</div></td>
              <td><div>{{item.chkOk}}</div></td>
              <td><div>{{item.chkDate}}</div></td>
            </tr>
          </template>
        </tbody>
      </table>
    </div>
  </section>
</template>

<script>
module.exports = {
  props: {
    propsForm: {
      type: Object,
      required: true,
    },
  },
  mounted() {
    console.log(this.propsForm)
  },
  data() {
    return {
      parameterData: JSON.parse(sessionStorage.getItem('parameterData'))
    }
  },
  computed: {
    total() {
      const list = this.propsForm.detailList;
      const total = list.reduce((pre, cur) => {
        pre += +cur.ordQty;
        return pre;
      }, 0);
      return +total.toFixed(2);
    },
    allTotal() {
      const list = this.propsForm.detailList;
      const total = list.reduce((pre, cur) => {
        pre += +(cur.ordQty * cur.price);
        return pre;
      }, 0);
      return +total.toFixed(2);
    }
  },
};
</script>

<style scoped>
section {
  --border: 1px solid #000;
  --bg-color: #b3ffb3;
}

.page {
  margin: auto;
  font-size: 14px;
  max-width: 297mm;
  width: 100%;
}

.title {
  font-size: 20px;
  line-height: 1.4;
  text-align: center;
  margin-bottom: 0.5em;
  font-weight: bold;
}

.form {
  margin-bottom: 0.5em;
  padding: 0 2em;
}
.form-row {
  display: flex;
  justify-content: space-between;
  line-height: 1.8;
  font-weight: 600;
}
.form-row > div {
  text-align: left;
  flex-basis: 25%;
}

table {
  font-size: 14px;
}
table th,
td {
  padding: 4px;
}
.table-col-mini {
  width: 3em;
}
.table-col-short {
  min-width: 3em;
}
.table-col {
  min-width: 6em;
}
.table-col-long {
  min-width: 32em;
}

.foot {
  margin: 3em 0;
}
.foot-row {
  display: flex;
  justify-content: space-between;
}
.foot-row > div > div {
  width: 1em;
}

.desc {
  margin-top: 3em;
}
.desc div {
  text-align: left;
  line-height: 1.6;
}

/* commom */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-left {
  text-align: left;
}

.bg-color {
  background-color: var(--bg-color);
}
.base-stamp {
  margin-top: 3em;
}
</style>